//**********************************************************
//    File Name: FrmViewHCWScheduleProfile.cs
//    Author: Team Motif
//    Date Created : 04/13/2007
//    Current Owner: Team Motif 
//                                                                            
//    Purpose: 
//    To view Home Care Worker Schedule and profile.
//
//	  Copyright 2007
//**********************************************************
using System;
using System.Collections.Generic;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Library;

namespace Elderhealth
{
    public partial class FrmViewHCWScheduleProfile : Form
    {
        /// <summary>
        /// Default constructor
        /// </summary>
        public FrmViewHCWScheduleProfile()
        {
            InitializeComponent();
        }

        /// <summary>
        /// Overloaded constructor (When HCW ID is known).
        /// </summary>
        public FrmViewHCWScheduleProfile(long tmpHCWID)
        {
            mHCWID = tmpHCWID;
            InitializeComponent();
        }

        /// <summary>
        /// Display the basic information for the Home Care Worker.
        /// </summary>
        private void FrmViewHCWScheduleProfile_Load(object sender, EventArgs e)
        {
            FillBasicInfo();
            
        }

        /// <summary>
        /// Retrieve the basic information for the home care worker.
        /// </summary>
        public void FillBasicInfo()
        {
            HomeCareWorker matchingWorker = HomeCareWorker.GetWorkerByID(mHCWID);
            if (!String.IsNullOrEmpty(matchingWorker.GetFirstName()))
                mFirstName.Text = matchingWorker.GetFirstName();
            if (!String.IsNullOrEmpty(matchingWorker.GetMiddleName()))
                mMiddleName.Text = matchingWorker.GetMiddleName();
            if (!String.IsNullOrEmpty(matchingWorker.GetLastName()))
                mLastName.Text = matchingWorker.GetLastName();
            if (!String.IsNullOrEmpty(matchingWorker.GetDateOfBirth().ToString()))
            {
                mDOB.Text = matchingWorker.GetDateOfBirth().ToShortDateString();
            }
            if (!String.IsNullOrEmpty(matchingWorker.GetPhoneNumber1()))
                mPhone1.Text = matchingWorker.GetPhoneNumber1();
            if (!String.IsNullOrEmpty(matchingWorker.GetPhoneNumber2()))
                mPhone2.Text = matchingWorker.GetPhoneNumber2();
            if (!String.IsNullOrEmpty(matchingWorker.GetAddress1()))
                mAddress1.Text = matchingWorker.GetAddress1();
            if (!String.IsNullOrEmpty(matchingWorker.GetAddress2()))
                mAddress2.Text = matchingWorker.GetAddress2();
            if (!String.IsNullOrEmpty(matchingWorker.GetCity()))
                mCity.Text = matchingWorker.GetCity();
            if (!String.IsNullOrEmpty(matchingWorker.GetState()))
                mState.Text = matchingWorker.GetState();
            if (!String.IsNullOrEmpty(matchingWorker.GetZipCode()))
                mZip.Text = matchingWorker.GetZipCode();
            if (!String.IsNullOrEmpty(matchingWorker.GetEmail()))
                mEmail.Text = matchingWorker.GetEmail();
            
        }

        //when 2nd tab is clicked for additional information
        private void tabPage2_Click(object sender, EventArgs e)
        {
            DisplayTaskList();
            DisplayCertList();
            DisplayConstWeekHoursForHCW();
        }

        /// <summary>
        /// This function talks to the Task class and get the data from the database
        /// </summary>
        private void DisplayTaskList()
        {
            
            Task TaskDetail;
            ArrayList tmpTaskList = new ArrayList();
            tmpTaskList = Library.Task.GetAllTasksForHCW(mHCWID);
            for (int i = 0; i < tmpTaskList.Count; i++)
            {
                TaskDetail = (Task)tmpTaskList[i];
                mSkills.Items.Add(TaskDetail.GetTaskName());
            }

        }

        /// <summary>
        /// This function gets all the constraints for a HCW from the database
        /// </summary>
        private void DisplayConstWeekHoursForHCW()
        {
            HomeCareWorker myHCW = HomeCareWorker.GetConstWeekHoursForHCW(mHCWID);
            Constraints.Text = myHCW.constraints;
            WeeklyHours.Text = myHCW.weeklyHrs.ToString();
            

        }


        /// <summary>
        /// This function talks to the Certificate structure and get the data from the database
        /// </summary>
        private void DisplayCertList()
        {
            
            Certification myCertList;
            ArrayList myArray = new ArrayList();
            
            myArray = Library.HomeCareWorker.GetCertificateForID(mHCWID);
            if (myArray.Count > 0)
            {
                for (int i = 0; i < myArray.Count; i++)
                {
                    myCertList = (Certification)myArray[i];
                    mCertifications.Items.Add(myCertList.CertName);
                }
            }
            else
            {
                mCertifications.Items.Add("None");
            }
        }


        private long mHCWID;

    }
}